/**
 * Created by ospip on 2017/10/17.
 * Copyright (c) 2017 LLAP. All rights reserved.
 */
public class ArrayAverage implements Average {
    int[] list;
    public ArrayAverage(int[] list) {
        this.list = list;
    }

    public ArrayAverage(String[] list) {
        try {
            this.list = new int[list.length];
            for (int i = 0; i < list.length; i++) {
                this.list[i] = Integer.parseInt(list[i]);
            }
        }
        catch (NumberFormatException e) {
            System.out.println(e.getMessage());
        }
    }

    @Override
    public double average() {
        int sum = 0;
        for (int i : list) sum += i;
        return sum / list.length;
    }

    public static void main(String[] args) {
        int[] list = {1,5,4,3,2,245,25,1,123,235,63,3,23,1};
        System.out.println(new ArrayAverage(list).average());
    }
}
